<template>
  <div class="header">
    <h2>教务管理系统</h2>
    <div class="logout" @click="logout">退出登录</div>
    <div class='role'>{{ getRole() }}</div>
    <div class='username'>{{ getUsername() }}</div>
    <el-avatar :size="50" :src=url style="margin-right: 10px;"></el-avatar>
  </div>
</template>

<script>
import router from '@/router';

export default {
  data() {
    return {
      url: require('../assets/imgs/bili-default.png'),
    }
  },
  methods: {
    getUsername(){
      return sessionStorage.getItem('username')
    },
    getRole(){
      return sessionStorage.getItem('role')
    },
    logout(){
      localStorage.clear()
      sessionStorage.clear()
      router.push('/login')
    }
  }
}
</script>

<style scoped>
h2 {
  text-shadow: 0 0 10px grey,0 0 20px grey,0 0 30px grey,0 0 40px grey;
  margin-right: auto;
  margin-left: 20px;
}

.header {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 10px 20px;
}

.role {
  color: #9c9b9b;
  margin-right: 10px;
  font-weight: 700;
  font-size: large;
}

.username{
  color: #9c9b9b;
  text-align: center;
  font-weight: 600;
  font-size: large;
  margin-right: 15px;
}

.logout {
  color: #fff;
  margin-right: 20px;
}

.logout:hover {
  transition: all 0.3s ease 0s;
  color: #ccc;
  cursor: pointer;
}

.logout:active {
  color: #f3f1f1;
}
</style>